init python:
    def tackle_distance(drags, drop):
        """实现检查碎片是否到达指定位置,当到达指定位置自动固定到该位置并切换到下一幕
        Args:
            drags:系统自动提供，拖拽的组件列表
            drop:当前掉落到的组件
        Return:

        """
        if not drags:
            return
        if not drop:
            renpy.notify("不在这里吗")
            return
        drag = drags[0]
        drag_center_x = drag.x + drag.w/2
        drag_center_y = drag.y + drag.h/2
        drop_center_x = drop.x + drop.w/2
        drop_center_y = drop.y + drop.h/2

        distance = ((drag_center_x - drop_center_x)**2 + (drag_center_y - drop_center_y)**2)**0.5
        int(drop_center_x)
        if distance <= 30:
            drag.snap(int(drop_center_x-drag.w/2),int(drop_center_y-drag.h/2), 0.2) # 一定要加int，不然就会消失哦
            drag.draggable = False #成功后禁止再次拖
            store.puzzle_completed =True
            renpy.notify("成功!")  
            renpy.jump("next")
            return #退出
        elif 30<distance<=100:
            renpy.notify("快到了")            
        else:
            renpy.notify("应该在附近吗")


screen drag_pages:
    draggroup:
        
        drag:
            drag_name "drag_1"
            child Solid("#8cff27",xsize=50,ysize=50)
            xpos 200 ypos 150
            draggable True
            drag_raise True  
            dragged tackle_distance
        drag:
            drag_name "drag_2"
            child Solid("#e9ff27",xsize=50,ysize=50)
            xpos 200 ypos 400
            draggable puzzle_completed
            drag_raise True  
            dragged tackle_distance
        drag:
            drag_name "target"
            child Solid("#0000ff", xsize=200, ysize=200) 
            xpos 400 ypos 300
            draggable False
            droppable True
            
#定义控制变量
default puzzle_completed = False        

label next:
    "成功嵌合了进去！"
    "第一块拼图放到了该放的地方"
    "可以放第二块了"
    return
label start:
    $ puzzle_completed = False # 不能进入到下一页
    show screen drag_pages
    "放置这块拼图吧"
    while not puzzle_completed:
        "再试试看..."  # 玩家点击时会显示这个提示
        pause 0.1
    
